home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / ixemlsrc.lha / ixemul / library / ixemul.h < prev    next >
C/C++ Source or Header  |  1995-12-31  |  7KB  |  291 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  ixemul.h,v 1.1.1.1 1994/04/04 04:29:38 amiga Exp
  20.  *
  21.  *  ixemul.h,v
  22.  * Revision 1.1.1.1  1994/04/04  04:29:38  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.4  1993/11/05  22:14:40  mwild
  26.  *  changes there, here...
  27.  *
  28.  *  Revision 1.3  1992/10/20  16:32:33  mwild
  29.  *  *** empty log message ***
  30.  *
  31.  *  Revision 1.2  1992/07/04  19:25:26  mwild
  32.  *  change __rwport to reflect the current state of the (now global) async port
  33.  *
  34.  * Revision 1.1  1992/05/14  20:36:14  mwild
  35.  * Initial revision
  36.  *
  37.  */
  38.  
  39. #ifndef _IXEMUL_H_
  40. #define _IXEMUL_H_
  41.  
  42. #ifdef START
  43.  
  44. /* definitions for the assembler startup file */
  45.  
  46. /* when I've REALLY lots of free time, I'll rewrite header files, but now... */
  47.  
  48. /* amazingly works, contains only defines ;-)) */
  49. #include <exec/alerts.h>
  50.  
  51. #define _LVOOpenLibrary        -0x228
  52. #define _LVOCloseLibrary     -0x19e
  53. #define _LVOAlert        -0x6c
  54. #define _LVOFreeMem        -0xd2
  55. #define _LVORemove        -0xfc
  56.  
  57. #define RTC_MATCHWORD    0x4afc
  58. #define RTF_AUTOINIT    (1<<7)
  59.  
  60. #define LIBF_CHANGED    (1<<1)
  61. #define LIBF_SUMUSED    (1<<2)
  62. /* seems there is an assembler bug in expression evaluation here.. */
  63. #define LIBF_CHANGED_SUMUSED 0x6
  64. #define LIBF_DELEXP    (1<<3)
  65. #define LIBB_DELEXP    3
  66.  
  67. #define LN_TYPE        8
  68. #define LN_NAME        10
  69. #define NT_LIBRARY    9
  70. #define MP_FLAGS    14
  71. #define PA_IGNORE    2
  72.  
  73. #define LIST_SIZEOF    14
  74.  
  75. #define THISTASK    276
  76.  
  77. #define INITBYTE(field,val)    .word 0xe000; .word (field); .byte (val); .byte 0
  78. #define INITWORD(field,val)    .word 0xd000; .word (field); .word (val)
  79. #define INITLONG(field,val)    .word 0xc000; .word (field); .long (val)
  80.  
  81. /*
  82.  * our library base.. 
  83.  */
  84.  
  85. /* struct library */
  86. #define    IXBASE_NODE    0
  87. #define IXBASE_FLAGS    14
  88. #define IXBASE_NEGSIZE    16
  89. #define IXBASE_POSSIZE    18
  90. #define IXBASE_VERSION    20
  91. #define IXBASE_REVISION    22
  92. #define IXBASE_IDSTRING    24
  93. #define IXBASE_SUM    28
  94. #define IXBASE_OPENCNT    32
  95. #define IXBASE_LIBRARY    34    /* size of library */
  96.  
  97. /* custom part */
  98. #define IXBASE_MYFLAGS        (IXBASE_LIBRARY + 0)
  99. #define IXBASE_SEGLIST        (IXBASE_MYFLAGS + 2)
  100. #define IXBASE_C_PRIVATE    (IXBASE_SEGLIST + 4)
  101.  
  102. #else  /* C-part */
  103.  
  104. #include <exec/types.h>
  105. #include <exec/libraries.h>
  106. #include <exec/execbase.h>
  107. #include <exec/ports.h>
  108. #include <libraries/dosextens.h>
  109.  
  110. #include <sys/types.h>
  111.  
  112. #ifdef KERNEL
  113. #define _INTERNAL_FILE
  114. #endif
  115.  
  116. #include <sys/file.h>
  117. #include <sys/param.h>
  118. #include <packets.h>
  119. #include <sys/syscall.h>
  120. #include <signal.h>
  121.  
  122. #ifdef KERNEL
  123. #include <user.h>
  124. #endif
  125.  
  126. #include <errno.h>
  127.  
  128. /* ix_flags defines */
  129.  
  130.    #define ix_do_not_flush_library             0x00001000
  131.    #define ix_allow_amiga_wildcard             0x00000800
  132.    #define ix_no_insert_disk_requester             0x00000400
  133.    #define ix_unix_pattern_matching_case_sensitive    0x00000200
  134. /* #define ix_unix_pattern_matching             0x00000100 obsolete */
  135. /* #define ix_no_ces_then_open_console             0x00000080 obsolete */
  136.    #define ix_ignore_global_env             0x00000040
  137. /* #define ix_disable_fibcache                 0x00000020 obsolete */
  138. /* #define ix_translate_dots                 0x00000010 obsolete */
  139.    #define ix_watch_stack                 0x00000008
  140. /* #define ix_force_translation             0x00000004 obsolete */
  141. /* #define ix_translate_symlinks             0x00000002 obsolete */
  142.    #define ix_translate_slash                0x00000001
  143.  
  144. /* ix_network_type enum */
  145.  
  146. enum
  147. {
  148.   IX_NETWORK_AUTO,
  149.   IX_NETWORK_NONE,
  150.   IX_NETWORK_AS225,
  151.   IX_NETWORK_AMITCP,
  152.   IX_NETWORK_END_OF_ENUM
  153. };
  154.  
  155. /* configure this to the number of hash queues you like, 
  156.  * use a prime number !!
  157.  */
  158. #define IX_NUM_SLEEP_QUEUES    31
  159.  
  160. struct ixemul_base {
  161.   struct Library        ix_lib;
  162.  
  163. /* don't use the remainder of the library base. The contents can change
  164.    without warning in the future. */
  165. #ifdef KERNEL
  166.   unsigned char            ix_myflags;    /* used by start.s */
  167.   unsigned char            ix_pad;
  168.   BPTR                ix_seg_list;    /* used by start.s */
  169.  
  170.   /* the global file table with current size */
  171.   struct file            *ix_file_tab;
  172.   struct file            *ix_fileNFILE;
  173.   struct file            *ix_lastf;
  174.  
  175.   /* size of start of red zone from bottom of stack */
  176.   int                ix_red_zone_size;
  177.  
  178.   struct SignalSemaphore    ix_semaph;
  179.   int                ix_membuf_limit;
  180.   
  181.   /* multiplier for id_BytesPerBlock to get to st_blksize, default 64 */
  182.   int                ix_fs_buf_factor;
  183.  
  184.   unsigned long            ix_flags;
  185.  
  186.   struct MinList        ix_sleep_queues [IX_NUM_SLEEP_QUEUES];
  187.  
  188.   struct MinList        ix_socket_list;
  189.   long                      ix_gmt_offset;
  190.   int                ix_network_type;
  191. #endif
  192. };
  193.  
  194.  
  195. /* this is the only prototype of library functions, that are really used inside
  196.  * the library. (So a user can patch a function, and the library will use
  197.  * the new entry, and not a hard compiled address */
  198. #define syscall(vec, args...) \
  199.   ({register int (*_sc)()=(void *)(&((char *)ixemulbase)[-((vec)+4)*6]); _sc(args);})
  200.  
  201. /* Structure to pass ixemul.library settings to/from the library base */
  202. struct ix_settings {
  203.   int version;
  204.   int revision;
  205.   unsigned long flags;
  206.   int membuf_limit;
  207.   int red_zone_size;
  208.   int fs_buf_factor;
  209.   int network_type;
  210. };
  211.  
  212. /* Environment name of ixemul settings */
  213. #define IX_ENV_SETTINGS "ixemul.prefs"
  214.  
  215. void ix_set_gmt_offset(long offset);
  216. long ix_get_gmt_offset(void);
  217. struct ix_settings *ix_get_default_settings(void);
  218. struct ix_settings *ix_get_settings(void);
  219. void ix_set_settings(struct ix_settings *settings);
  220.  
  221. #ifdef KERNEL
  222.  
  223. #include <ixprotos.h>
  224.  
  225. extern struct ixemul_base *ixemulbase;
  226.  
  227. #define ix (*ixemulbase)
  228. #define u (*(struct user *)((*(struct ExecBase **)4)->ThisTask->tc_TrapData))
  229.  
  230. static inline u_int get_usp (void) 
  231.   u_int res;
  232.  
  233.   asm volatile ("movel    usp,%0" : "=a" (res));
  234.   return res;
  235. }
  236.  
  237. static inline void set_usp (u_int new_usp)
  238. {
  239.   asm volatile ("movel  %0,usp" : /* no output */ : "a" (new_usp));
  240. }
  241.  
  242. static inline u_int get_sp (void) 
  243.   u_int res;
  244.  
  245.   asm volatile ("movel    sp,%0" : "=a" (res));
  246.   return res;
  247. }
  248.  
  249. static inline void set_sp (u_int new_sp)
  250. {
  251.   asm volatile ("movel  %0,sp" : /* no output */ : "a" (new_sp));
  252. }
  253.  
  254. static inline u_short get_sr (void) 
  255.   u_short res;
  256.  
  257.   asm volatile ("movew    sr,%0" : "=g" (res));
  258.   return res;
  259. }
  260.  
  261. static inline u_int get_fp (void) 
  262.   u_int res;
  263.  
  264.   asm volatile ("movel    a5,%0" : "=g" (res));
  265.   return res;
  266. }
  267.  
  268. #define PRIVATE
  269. extern struct ExecBase *SysBase;
  270. #include <inline/exec.h>
  271. #undef PRIVATE
  272.  
  273. extern struct DosLibrary *DOSBase;
  274. #include <inline/dos.h>
  275.  
  276. #define errno (* u.u_errno)
  277.  
  278. extern struct MsgPort *ix_async_mp;
  279. #define __rwport (ix_async_mp)
  280. #define __srwport (u.u_sync_mp)
  281.  
  282. #endif /* KERNEL */
  283.  
  284. #endif /* START */
  285.  
  286. #endif /* _IXEMUL_H */
  287.